<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:dxl="http://www.lotus.com/dxl"
    xmlns:session="java:ro.egmar.dojocache.extensions.SessionExtension"
    exclude-result-prefixes="session xs dxl">
    
    <!-- Output options -->
    <xsl:output
        method="html"
        omit-xml-declaration="yes"
        indent="yes"
    />
    
    <!-- Global parameters -->
    <xsl:param name="webDbPath"/>
    <xsl:param name="notesDbPath"/>
    <xsl:param name="mode"/>
    <xsl:param name="unid"/>
    
    <!-- Richtext stylesheet -->
    <xsl:include href="data/xsl/richtext.xsl"/>
    
    <!-- Fields stylesheet -->
    <xsl:include href="data/xsl/fields.xsl"/>
    
    <!-- Strip whitespace -->
    <xsl:strip-space elements="*"/>
    
    <!-- Overriding default templates -->
    <xsl:template match="text()|@*" />
    
    <!-- Tempalte for section -->
    <xsl:template match="dxl:section">
        <div dojoType="TitlePane" label="{dxl:sectiontitle/dxl:text/text()}" open="false">
            <xsl:apply-templates/>
        </div>
    </xsl:template>
    
    <!-- Template for tabbed table -->
    <xsl:template match="dxl:table[@rowdisplay='tabs']">
        <div dojoType="TabContainer" style="height:200px;">
            <xsl:apply-templates/>
        </div>
    </xsl:template>
    
    <!-- Template for tabbed table row -->
    <xsl:template match="dxl:table[@rowdisplay='tabs']/dxl:tablerow">
        <div dojoType="ContentPane" id="{position()}" label="{@tablabel}">
            <xsl:apply-templates/>    
        </div>
    </xsl:template> 
    
    <!-- Template for captions table -->
    <xsl:template match="dxl:table[@rowdisplay='captions']">
        <div dojoType="AccordionContainer" 
            labelNodeClass="label" 
            containerNodeClass="accBody" 
            style="height:200px;">
            <xsl:apply-templates/>
        </div>
    </xsl:template>
    
    <!-- Template for captions table row -->
    <xsl:template match="dxl:table[@rowdisplay='captions']/dxl:tablerow">
        <div dojoType="ContentPane" label="{@tablabel}">
            <xsl:apply-templates/>    
        </div>
    </xsl:template>
    
    <!-- Template for embeddedview element -->
    <xsl:template match="dxl:embeddedview">
        <div dojoType="DominoView" 
            view="{@name}" 
            dbReplica="{@database}"/>
    </xsl:template>
    
    <!-- Template for embeddeddatepicker element -->
    <xsl:template match="dxl:embeddeddatepicker">
        <div dojoType="DatePicker"/>
    </xsl:template>
    
    <!-- Template for embeddedoutline widget -->
    <xsl:template match="dxl:embeddedoutline">
        <xsl:param name="name"/>
        <div dojoType="DominoOutlinePane"
            categorySymbols="simple"
            orientation="{@display}"
            contentPane="{@targetframe}"
            display="{@type}" 
            outlineName="{@outline}">
        </div>
    </xsl:template>
    
    <!-- Template for subform element -->
    <xsl:template match="dxl:subformref">
        <div dojoType="DominoSubform" subform="{@name}"/>
    </xsl:template>
    
    <!-- Template for sharedfield element -->
    <xsl:template match="dxl:sharedfieldref">
        <div dojoType="DominoSharedfield" sharedfield="{@name}"/>
    </xsl:template>
    
    <!-- Template for form element -->
    <xsl:template match="dxl:subform">
<div>
        <xsl:apply-templates>
            <xsl:with-param name="name" select="translate(@name,' ','')" />
        </xsl:apply-templates> 
</div>  
    </xsl:template>
    
    <!-- Root template, main entry point -->
    <xsl:template match="/">
        <xsl:apply-templates/>
    </xsl:template>
    
</xsl:stylesheet>